
<?
	  include("/inc/header.html") {}
    ?>    
    
    <link rel="stylesheet" href="static/uploadify/uploadify.css" type="text/css"></link>
	<script type="text/javascript" src="static/uploadify/jquery.uploadify.min.js"></script>
    <script type="text/javascript" src="static/utf8-jsp/ueditor.config.js"></script>
	<script type="text/javascript" src="static/utf8-jsp/ueditor.all.js"></script>
	<script type="text/javascript" src="static/utf8-jsp/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" src="static/utf8-jsp/third-party/video-js/video.js"></script>
     
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <div class="panel panel">       
                                                <div class="panel-body pan" style="height: 400px">                                                                          
                                                        <div class="form-body pal" >
                                                            <div >
                                                                <label for="inputUsername" class="col-md-3 control-label">数据导入名称 <span class='require'>*</span>
                                                                </label>
                                                                <div class="col-md-9">
                                                                    <div class="input-icon">
                                                                        <input id="name" type="text" class="form-control"  />
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div>
                                                             <label for="inputUsername" class="col-md-3 control-label">数据导入描述 <span class='require'>*</span>
                                                                </label>
                                                                <div class="col-md-9">
                                                                    <div class="input-icon">
                                                                        <input id="description" type="text"class="form-control" />
                                                                    </div>
                                                                </div>
                                                            </div>
                                                                   <div >
							                                        <label for="inputUsername" class="col-md-3 control-label">数据源名称<span class='require' >*</span> </label>
							                                         <div class="col-md-9">
								                                         <div class="input-group input-group-sm mbs" >
									                                         <input id="shujuname" type="text" placeholder=""  class="form-control" disabled="true"  />
									                                           <span class="input-group-btn"><button  onclick="shuju()" type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle">选择...</button></span>		
									                                           <input id="dataSourceId" type="hidden" value="" class="form-control" />
								                                       </div>
							                                      </div>
                                                              <div >
							                                        <label for="inputUsername" class="col-md-3 control-label">知识库名称<span class='require' >*</span> </label>
							                                         <div class="col-md-9">
								                                         <div class="input-group input-group-sm mbs" >
									                                         <input id="parentclassname" type="text" placeholder=""  class="form-control" disabled="true"  />
									                                                     <span class="input-group-btn"><button  onclick="saveclassZTree()" type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle">选择...</button></span>		
									                                           <input id="parentClassid" type="hidden" value="" class="form-control" />
								                                       </div>
							                                      </div>
						                                          <div >
							                                        <label for="inputUsername" class="col-md-3 control-label">上传导入excel<span class='require' >*</span> </label>
							                                         <div class="col-md-9">
								                                         <div class="input-group input-group-sm mbs" >
								                                         <br>
									                                     <!--  <input type="file" id="uploadify" name="uploadify" class="form-control" > -->
									                                     
									                                      <span class="input-group-btn">
									                                      <button  onclick="upFiles()" type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle">上传...</button></span>
		                                                           <!--  <span class="input-group-btn"><button  onclick="uploadcancel()" type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle">开始上传</button></span>
                                                                   
                                                                   --></div> 
                                                                   <textarea id="uploadImage" name="uploadImage"></textarea>
                                                                   	 <div id="filepathpp" ></div>
                                                                      <!-- <span id="fileQueue"></span> -->
							                                      </div>  
                                                        </div>
                                                </div>
                                            </div>
                                         </div></div>
                                  </div></div>
           
  <script type="text/javascript">
  
  var falg =0;
  var tt="";
  var _editor;
	 $(function(){  
        _editor = UE.getEditor('uploadImage');
	    _editor.ready(function (){
	        //设置编辑器不可用(事实上不可以设置不可用...所以注释掉,以观后效)
	        _editor.setDisabled();
	        //隐藏编辑器,因为只使用上传功能
	        _editor.hide();
	        //侦听图片上传
	  	 	_editor.addListener('beforeInsertImage',function(t,arg){
	  	 		
	        });
	        //侦听文件上传
		   	 _editor.addListener('afterUpfile',function(t,arg){
		   	 	for(var i=0;i<arg.length;i++){
	  	 			var urlFile = arg[i].url;
	  	 			falg=1; 
	                document.getElementById('filepathpp').innerHTML='文件上传成功！<a href="'+urlFile+'" download="w3logo"><img src="static/images/wj.jpg" width="30" height="30" /></a>';
	                tt=urlFile;
	  	 		}
		   	 });
	   }); 
            
    });
     //上传文件
	function upFiles() {
		var myFiles = _editor.getDialog("attachment");
	   	myFiles.open();
	}
    function uploadbutten()
    {
	$('#uploadify').uploadify('upload','*');
	}
	function uploadcancel()
    {
	$('#uploadify').uploadify('cancel');
	}
  //数据源
	function shuju() {
		parent.layer.open({
			type : 2,
			area : [ '700px', '530px' ],
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,
			//move : false,
			title:"选择数据源",
			skin : 'layui-layer-rim', //加上边框
			btn : [ '保存 ', '关闭' ],
			content : ["data-import-source-from.html?winName="+window.name, 'no'],
			yes : function(index,layer) {		
			  var iframeWin = parent.window[layer.find('iframe')[0]['name']];
			   iframeWin.save();
			},
			cancel : function(index) {
			}
		});
	};
 	function saveclassZTree() {
		parent.layer.open({
			type : 2,
			area : [ '500px', '400px' ],
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,
			///move : false,
			title:"导入数据的类",
			skin : 'layui-layer-rim', //加上边框
			btn : [ '保存 ', '关闭' ],
			content : ["knowledge-Classes-class-zTree.html?winName="+window.name, 'no'],
			yes : function(index,layer) {		
			  var iframeWin = parent.window[layer.find('iframe')[0]['name']];
			  			  iframeWin.save();
			},
			cancel : function(index) {
			}
		});
	};
	 
function save() {  
 
                 if($.trim($("#name").val()).length<1) {
    	        	alert('数据导入名称不能为空！');
    	        	return null;
    	        }
    	         if($.trim($("#description").val()).length<1) {
    	        	alert('数据导入描述不能为空！');
    	        	return null;
    	        }
    	         if($.trim($("#dataSourceId").val()).length<1) {
    	        	alert('数据来源不能为空！');
    	        	return null;
    	        }
    	         if($("#parentClassid").val()==0) {
    	        	alert('所属类不能为空！');
    	        	return null;
    	        }   
    	      if(falg==0)
    	      {
    	      alert('上传文件不能为空！');
    	        	return null;
    	      }
    	       
    $.ajax({  
                type : "post",  
                url : "./KnowledgeImportsave.do",  
                data : {
                "name":$("#name").val(),
                "description":$("#description").val(),
                "dataSourceId":$("#dataSourceId").val(),
                "classesId":$("#parentClassid").val(),
                "path":tt
                },
                dataType : "json", 
                async:false,  
                success : function(data) { 
                     var index = parent.layer.getFrameIndex(window.name); 
           window.parent.get();
            parent.layer.msg('添加或编辑成功');
            parent.layer.close(index); 
                },
	            error : function(data) {
                   alert("请求失败");
		        }
            });

          
    }  
 
  
</script>


